import React from 'react';
import { Form, Input } from 'antd';
import OrganizationSelect from '@/components/OrganizationSelect';
import BudgetSelect from '@/components/BudgetSelect';
import BudgetSourceSelect from '@/components/BudgetSourceSelect';
import { useModel } from 'umi';

const Content = React.forwardRef((props, ref) => {
  const { initialState } = useModel('@@initialState');
  const unitId = props.id || initialState.currentUser.unitId;
  return (
    <Form
      ref={ref}
      labelCol={{ span: 6 }}
      wrapperCol={{ span: 16 }}
      layout="horizontal">
      <Form.Item
        name='benefitUnitId'
        rules={[{ required: true, message: '请选择预算机构！' }]}
        label='预算机构：'>
        <OrganizationSelect />
      </Form.Item>
      <Form.Item
        name='code'
        label='预算名称：'
        rules={[{ required: true, message: '请输入预算名称' }]}>
        <Input placeholder='请输入预算名称' />
      </Form.Item>
      <Form.Item
        name='sourceType'
        label='预算来源：'
        rules={[{ required: true, message: '请选择预算来源' }]}>
        <BudgetSourceSelect />
      </Form.Item>
      <Form.Item
        name='amount'
        label='预算金额：'
        rules={[{ required: true, message: '请输入预算金额' }]}>
        <Input placeholder='请输入预算金额' />
      </Form.Item>
      <Form.Item
        name='parentBudgetId'
        label='所属预算：'
        rules={[{ required: true, message: '请选择所属预算' }]}>
        <BudgetSelect id={unitId} />
      </Form.Item>
      <Form.Item
        name='remark'
        label='备注：'>
        <Input.TextArea placeholder='请输入备注' />
      </Form.Item>
    </Form>
  )
})

export default Content